package demo05;

/**
 * @author: WangPeng
 * @createTime: 2022/11/01 16:55
 * @description:
 * @version: v1.0
 */
public class TestPriority {
    public static void main(String[] args) {
        PriorityDemo priorityDemo1 = new PriorityDemo("线程A");
        PriorityDemo priorityDemo2 = new PriorityDemo("线程B");
        PriorityDemo priorityDemo3 = new PriorityDemo("线程C");
        //优先级值越大 获取cpu的概率越高  执行完越早
        priorityDemo1.setPriority(1);
        priorityDemo1.setPriority(5);
        priorityDemo1.setPriority(10);
        priorityDemo1.start();
        priorityDemo2.start();
        priorityDemo3.start();
    }
}
class PriorityDemo extends Thread{
    public PriorityDemo (String name){
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName()+"正在执行==="+i);
        }
    }
}
